package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.*;

@Getter
@Setter
@ToString
@JsonIgnoreProperties("handler")
public class Friendship  extends BaseDomain{

    private User user;

    private String content;

    private String images;

    @JsonFormat(pattern = "HH:mm MM月dd日")
    private Date createTime;

    //评论集合
    private List<FriendshipComment> friendshipComments =new ArrayList<>();

    //点赞用户集合
    private List<User> friendshipPraises =new ArrayList<>();

    //当前用户是否对这条朋友圈点赞
    private Boolean isGood=false;

    public String[] getImgArr(){
        String[] split=null;
        if (images != null) {
            split = images.split(";");
        }

        return split;
    }


    public Object getJson(){
        Map<String,Object> map = new HashMap<>();
        if (user != null) {
            map.put("bepraiseuserId",user.getId());
        }
        map.put("friendshipId",id);
        map.put("isGood",isGood);
        return JSONUtil.toJSONString(map);
    }
}